package lab03.test05;

import java.io.*;
import java.util.Arrays;
import java.util.Scanner;

    public class Test05 {
        public static void main(String[] args) {

            File file = new File("F:\\java实验三第五题.txt");
            FileWriter fileWriter = null;
            FileReader fileReader = null;

            Scanner sc = new Scanner(System.in);
            System.out.println("请输入字符串：");
            String string = sc.next();

            char[] b = string.toCharArray();
            char[] a = new char[b.length];
            for (int i = 0;i < b.length;i ++){
                a[i] = (char) ((int)b[i] + 1);
            }
            System.out.println(a);

            try {
                fileWriter = new FileWriter(file);
                fileReader = new FileReader(file);
                fileWriter.write(Arrays.toString(a));

                int data = 0;
                while ((data = fileReader.read()) != -1){
                    System.out.println((char) data);
                }
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
